package com.dlut.txy.designpattern.listener.event;

import com.dlut.txy.designpattern.listener.enums.QrcodeStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
// 二维码状态变更事件
public class QrcodeStatusModifyEvent {

    private QrcodeStatus preStatus;
    private QrcodeStatus status;


    @Data
    @NoArgsConstructor
    // 新生成事件
    public static class Created extends QrcodeStatusModifyEvent {
        private String createTime;
        public Created(String createTime) {
            super(null, QrcodeStatus.CREATED);
            this.createTime = createTime;
        }
    }

    @Data
    @NoArgsConstructor
    // 已扫码事件
    public static class Scanned extends QrcodeStatusModifyEvent {
        private String scanTime;
        public Scanned(String scanTime) {
            super(QrcodeStatus.CREATED, QrcodeStatus.SCANNED);
            this.scanTime = scanTime;
        }
    }

    @Data
    @NoArgsConstructor
    // 已过期事件
    public static class Expired extends QrcodeStatusModifyEvent {
        private String expiredTime;
        public Expired(String expiredTime) {
            super(QrcodeStatus.CREATED, QrcodeStatus.EXPIRED);
            this.expiredTime = expiredTime;
        }
    }
}
